<template>
  <header class="login-header">
    <div class="container m-top-20">
      <h1 class="logo">
        <RouterLink to="/">多倍</RouterLink>
      </h1>
      <RouterLink class="entry" to="/">
        进入网站首页
        <i class="iconfont icon-angle-right"></i>
        <i class="iconfont icon-angle-right"></i>
      </RouterLink>
    </div>
  </header>
  <div class="home_login" :style="'background: url('+ '/src/assets/Home/user_login__bgs.png' +');'">
    <div class="login_block w1200">
      <div class="login_item">
        <div class="login_title">
          <ul>
            <li class="red">忘记密码</li>
            <li>|</li>
            <li @click="$router.push('/home/login')">账号登录</li>
          </ul>
        </div>
        <div class="login_input">
          <div class="input_block"><input type="text" v-model="data.username" placeholder="手机"
                                          @keyup.enter="forgetPassword"></div>
          <div class="input_block"><input type="password" v-model="data.password" placeholder="新密码"
                                          @keyup.enter="forgetPassword"></div>
          <div class="input_block"><input type="password" v-model="data.re_password" placeholder="确认密码"
                                          @keyup.enter="forgetPassword"></div>
          <div class="input_block">
            <input class="yzm" type="code" v-model="data.code" placeholder="请输入"
                   @keyup.enter="forgetPassword">
            <span :class="data.math>0?'yzmbtn dis':'yzmbtn'" @click="sendSms">{{ data.code_text }}</span>
          </div>
        </div>

        <div class="login_btn" @click="forgetPassword">确 定</div>

        <div class="login_btn_b">
          <router-link to="/home/login">立即登录?</router-link>
        </div>


      </div>
    </div>
  </div>
  <footer class="login-footer">
    <div class="container">
      <p>
        <a href="javascript:;">关于我们</a>
        <a href="javascript:;">帮助中心</a>
        <a href="javascript:;">售后服务</a>
        <a href="javascript:;">配送与验收</a>
        <a href="javascript:;">商务合作</a>
        <a href="javascript:;">搜索推荐</a>
        <a href="javascript:;">友情链接</a>
      </p>
      <p>CopyRight &copy; 多倍</p>
    </div>
  </footer>
</template>

<script setup lang="ts">
import {reactive} from "vue"

const data = reactive({
  username: "",
  password: "",
  re_password: "",
  code: "",
  code_text: '发送验证码',
  timeObj: null,
  math: 0,
})
const forgetPassword =()=>{}
const sendSms=()=>{}
// export default {
//     setup(props) {
//         const {ctx,proxy} = getCurrentInstance()
//         const store = useStore()
//         const router = useRouter()
//         const data = reactive({
//             username: "",
//             password: "",
//             re_password: "",
//             code: "",
//             code_text:'发送验证码',
//             timeObj:null,
//             math:0,
//         })
//
//         const forgetPassword = async ()=>{
//             if (data.username == "" || data.password == "") {
//                 proxy.$message.error(proxy.$t('msg.loginAbn'));
//                 return;
//             }
//
//             if (data.password != data.re_password) {
//                 proxy.$message.error(proxy.$t('msg.reInputError'));
//                 return;
//             }
//
//             let loginData = await proxy.R.post('/forget_password',{
//                 username: data.username,
//                 password: data.password,
//                 re_password: data.re_password,
//                 code: data.code,
//                 type:'phone',
//             })
//
//             loginData.routeUriIndex = store.state.load.routeUriIndex
//             if(!loginData.code){
//                 proxy.$message.success(proxy.$t('msg.success'))
//                 await store.commit('login/loginAfter',loginData)
//                 router.push('/')
//             }
//         }
//
//         // 发送短信
//         const sendSms = ()=>{
//             if(data.username == ''){
//                 return proxy.$message.error(proxy.$t('sms.phoneEmpty'));
//             }
//             if(data.math>0){
//                 return proxy.$message.error(proxy.$t('manySend'));
//             }
//             proxy.R.post('/sms',{phone:data.username,name:'forget_password'}).then(res=>{
//                 if(!res.code) return proxy.$message.success(proxy.$t('sms.sendSuc'))
//             })
//         }
//
//         return {
//             data,
//             forgetPassword,sendSms
//         }
//     }
// };
</script>
<style lang="scss" scoped>
.login_block {
  text-align: right;

  .login_btn_b {
    text-align: right;
    font-size: 12px;
    margin-top: 15px;
    margin-bottom: 40px;

    a {
      margin: 0 8px;
      color: #999;
    }
  }

  .login_item {
    width: 400px;
    background: #fff;
    height: 450px;
    float: right;
    box-sizing: border-box;
    padding: 40px;
    margin-top: 50px;
    text-align: left;

    .login_btn {
      cursor: pointer;
      color: #fff;
      background: #ca151e;
      line-height: 35px;
      width: 100%;
      text-align: center;
      font-size: 16px;
    }

    .login_input {
      margin-top: 30px;

      .input_block {
        margin: 15px auto;
        width: 320px;

        .yzmbtn {
          cursor: pointer;
          width: 140px;
          height: 35px;
          line-height: 35px;
          display: inline-block;
          text-align: center;
          background: #333;
          color: #fff;

          &.dis {
            background: #ccc;
            color: #666;
          }
        }

        input {
          width: 100%;
          border: 1px solid #e1e1e1;
          height: 35px;
          text-indent: 6px;
          outline: none;

          &.yzm {
            width: 50%;
            margin-right: 5%;
          }
        }
      }
    }

    .login_title {
      ul {
        margin-left: 55px;

        &:after {
          content: '';
          display: block;
          clear: both;
        }
      }

      ul li {
        cursor: pointer;
        float: left;
        margin-right: 20px;
        font-size: 20px;

        &.red {
          color: #ca151e;
        }

        &:hover {
          color: #ca151e;
        }
      }
    }
  }
}

.home_login {
  height: 550px;
}
.login-header {
  background: #fff;
  border-bottom: 1px solid #e4e4e4;

  .container {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
  }

  .logo {
    width: 200px;

    a {
      display: block;
      height: 132px;
      width: 100%;
      text-indent: -9999px;
      background: url("@/assets/images/logo.png") no-repeat center 18px / contain;
    }
  }

  .sub {
    flex: 1;
    font-size: 24px;
    font-weight: normal;
    margin-bottom: 38px;
    margin-left: 20px;
    color: #666;
  }

  .entry {
    width: 120px;
    margin-bottom: 38px;
    font-size: 16px;

    i {
      font-size: 14px;
      color: $xtxColor;
      letter-spacing: -5px;
    }
  }
}

.login-section {
  background: url('@/assets/images/login-bg.png') no-repeat center / cover;
  height: 488px;
  position: relative;

  .wrapper {
    width: 380px;
    background: #fff;
    position: absolute;
    left: 50%;
    top: 54px;
    transform: translate3d(100px, 0, 0);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
  }
}

.login-footer {
  padding: 30px 0 50px;
  background: #fff;

  p {
    text-align: center;
    color: #999;
    padding-top: 20px;

    a {
      line-height: 1;
      padding: 0 10px;
      color: #999;
      display: inline-block;

      ~a {
        border-left: 1px solid #ccc;
      }
    }
  }
}

.subBtn {
  background: $xtxColor;
  width: 100%;
  color: #fff;
}
</style>